import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 设备完成时长统计图
export function getEquipmentStats() {
  return request({
    url: '/wareHouses/mtbf',
    method: 'get'
  })
}

// 帕累托图
export function getFaultAnalysis() {
  return request({
    url: '/wareHouses/NumberOfFailures',
    method: 'get'
  })
}

// 设备类型统计故障
export function getFailureStatistics(params) {
  return request({
    url: '/wareHouses/NumberOfPower',
    method: 'get',
    params
  })
}

// 聚类分析
export function getClusterAnalysis() {
  return request({
    url: '/wareHouses/clusterAnalysis',
    method: 'get'
  })
}

// 控制图
export function getControlChartData() {
  return request({
    url: '/wareHouses/control',
    method: 'get'
  })
}

// 设备类型统计故障次数柱状图
export function getFaultDetails(deviceType, params) {
  return request({
    url: `/wareHouses/faultDetails/${deviceType}`,
    method: 'get',
    params
  })
}

// 原有的聊天相关 API
export function smartGenerateChart(data) {
  return request({
    url: '/chart/smartGenerate',
    method: 'post',
    data
  })
}

export function generateDiagram(data) {
  return request({
    url: '/zhishiku/chat/generate-diagram',
    method: 'post',
    data: data
  })
}

// 创建会话
export function createSession(data) {
  return request({
    url: '/zhishiku/chat/create/session',
    method: 'post',
    data: data
  })
}

// 查询会话列表
export function getSessions(data) {
  return request({
    url: '/zhishiku/chat/getsessions',
    method: 'post',
    data: data
  })
}

//获取会话内容
export function getChatList(data) {
  return request({
    url: '/zhishiku/chat/getsession',
    method: 'post',
    data: data
  })
}

//删除会话
export function delSession(data) {
  return request({
    url: '/zhishiku/chat/deleteSessions',
    method: 'post',
    data: data
  })
}

//发送聊天内容
export function Chat(data) {
  return request({
    url: '/zhishiku/chat/completion',
    method: 'post',
    data: data
  })
}

//更新会话
export function updataSession(data,sessionId) {
  return request({
    url: '/zhishiku/chat/session/'+sessionId,
    method: 'put',
    data: data
  })
}

// 上传文件到会话
export function uploadFileToChat(data) {
  return request({
    url: '/api/upload/file',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data
  })
}

// 上传图片到会话
export function uploadImageToChat(data) {
  return request({
    url: '/api/upload/image',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data
  })
}